<!DOCTYPE html>



  


<html class="theme-next pisces use-motion" lang="zh-Hans">
<head>
  <!-- hexo-inject:begin --><!-- hexo-inject:end --><meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="msyql,message queue," />










<meta name="description" content="整体启动main.py 通过多线程同时进行三个任务 (确保每个环境只有一个进程在运行)nohup python main.py&amp;amp; 相关配置配置写在文件 db.conf中只需要根据运行环境更改数据库的配置名称即可，如：oa = operationActivity.OperationActivity(“database_dev”) // 192oa = operationActivity.Op">
<meta name="keywords" content="msyql,message queue">
<meta property="og:type" content="article">
<meta property="og:title" content="资讯推送|用户推广|活动管理">
<meta property="og:url" content="http://yoursite.com/2017/02/14/message_pushing/index.html">
<meta property="og:site_name" content="Frone&#39;s Blog">
<meta property="og:description" content="整体启动main.py 通过多线程同时进行三个任务 (确保每个环境只有一个进程在运行)nohup python main.py&amp;amp; 相关配置配置写在文件 db.conf中只需要根据运行环境更改数据库的配置名称即可，如：oa = operationActivity.OperationActivity(“database_dev”) // 192oa = operationActivity.Op">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2018-07-13T11:06:08.777Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="资讯推送|用户推广|活动管理">
<meta name="twitter:description" content="整体启动main.py 通过多线程同时进行三个任务 (确保每个环境只有一个进程在运行)nohup python main.py&amp;amp; 相关配置配置写在文件 db.conf中只需要根据运行环境更改数据库的配置名称即可，如：oa = operationActivity.OperationActivity(“database_dev”) // 192oa = operationActivity.Op">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Pisces',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://yoursite.com/2017/02/14/message_pushing/"/>





  <title>资讯推送|用户推广|活动管理 | Frone's Blog</title><!-- hexo-inject:begin --><!-- hexo-inject:end -->
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <!-- hexo-inject:begin --><!-- hexo-inject:end --><div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">Frone's Blog</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">技术小窝</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-commonweal">
          <a href="/404/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-heartbeat"></i> <br />
            
            公益404
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2017/02/14/message_pushing/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Frone Xie">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Frone's Blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">资讯推送|用户推广|活动管理</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-02-14T02:14:14+08:00">
                2017-02-14
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/IMORA/" itemprop="url" rel="index">
                    <span itemprop="name">IMORA</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          
             <span id="/2017/02/14/message_pushing/" class="leancloud_visitors" data-flag-title="资讯推送|用户推广|活动管理">
               <span class="post-meta-divider">|</span>
               <span class="post-meta-item-icon">
                 <i class="fa fa-eye"></i>
               </span>
               
                 <span class="post-meta-item-text">阅读次数&#58;</span>
               
                 <span class="leancloud-visitors-count"></span>
             </span>
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h3 id="整体启动"><a href="#整体启动" class="headerlink" title="整体启动"></a>整体启动</h3><p>main.py</p>
<p>通过多线程同时进行三个任务 (确保每个环境只有一个进程在运行)<br>nohup python main.py&amp;</p>
<h4 id="相关配置"><a href="#相关配置" class="headerlink" title="相关配置"></a>相关配置</h4><p>配置写在文件 db.conf中<br>只需要根据运行环境更改数据库的配置名称即可，如：<br>oa = operationActivity.OperationActivity(“database_dev”) // 192<br>oa = operationActivity.OperationActivity(“database_prd”) // 125</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br></pre></td><td class="code"><pre><span class="line"># !/Users/xieqj/py_env/venv python</span><br><span class="line"># -*- coding: utf-8 -*-</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">import threading</span><br><span class="line">from mg_handling import msgPushing, userPromotion, operationActivity</span><br><span class="line">import util.comm as cm</span><br><span class="line">import time</span><br><span class="line"></span><br><span class="line"># 资讯推送</span><br><span class="line">def msg_pushing():</span><br><span class="line">    while (True):</span><br><span class="line">        mp = msgPushing.MsgPushing()</span><br><span class="line">        msg_contents = mp.scanDBForSending()</span><br><span class="line">        mp.insert_msg2mq(msg_contents)</span><br><span class="line">        mp.mark_msg_as_sent(msg_contents)</span><br><span class="line">        mp.close_database()</span><br><span class="line">        time.sleep(8)</span><br><span class="line"></span><br><span class="line"># 用户推广</span><br><span class="line">def user_promotion():</span><br><span class="line">    while (True):</span><br><span class="line">        mp = userPromotion.UserPromotion()</span><br><span class="line">        msg_contents = mp.scanDBForSending()</span><br><span class="line">        mp.insert_msg2mq(msg_contents)</span><br><span class="line">        mp.mark_msg_as_sent(msg_contents)</span><br><span class="line">        mp.close_database()</span><br><span class="line">        time.sleep(8)</span><br><span class="line"></span><br><span class="line"># 活动管理</span><br><span class="line">def operation_activity():</span><br><span class="line">    while (True):</span><br><span class="line">        oa = operationActivity.OperationActivity()</span><br><span class="line">        msg_contents = oa.scanDBForSending()</span><br><span class="line">        oa.insert_msg2mq(msg_contents)</span><br><span class="line">        oa.mark_msg_as_sent(msg_contents)</span><br><span class="line">        oa.close_database()</span><br><span class="line">        time.sleep(8)</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"># 通过多线程同时启动两个步骤</span><br><span class="line">if __name__ == &quot;__main__&quot;:</span><br><span class="line">    cm.initLog(&quot;pushing.log&quot;, &quot;INFO&quot;)</span><br><span class="line">    threads = []</span><br><span class="line">    t1 = threading.Thread(target=msg_pushing)</span><br><span class="line">    threads.append(t1)</span><br><span class="line">    t2 = threading.Thread(target=user_promotion)</span><br><span class="line">    threads.append(t2)</span><br><span class="line">    t3 = threading.Thread(target=operation_activity)</span><br><span class="line">    threads.append(t3)</span><br><span class="line">    for t in threads:</span><br><span class="line">        t.setDaemon(True)</span><br><span class="line">        t.start()</span><br><span class="line">    t.join()</span><br></pre></td></tr></table></figure>
<h3 id="资讯推送"><a href="#资讯推送" class="headerlink" title="资讯推送"></a>资讯推送</h3><p>读取表 sns_qa_push_setting 中的资讯，将其按照region，industry，func（职能）推送给对应群组的用户。<br>具体方法就是将表 sns_qa_push_setting 中的 content 1对1的推送给表 account_basic 中对应群组的用户，即插入 message_queue 表。</p>
<p>需要注意控制推送时间，和在推送后 update 表 sns_qa_push_setting 中 status 字段</p>
<h4 id="仓库位置"><a href="#仓库位置" class="headerlink" title="仓库位置"></a>仓库位置</h4><p>git@192.168.30.251:message_handling.git</p>
<p>{“messagetype”: 230,”params”: { “data”: [{“newsid”: “ EwtNMSASOSvxjerhni98uQyEXnDIp9fS”,”title”: “发布到审核”,”url”: “资讯  URL”, “coverurl”: “https: //oradtdev.s3.cn-north-  1.amazonaws.com.cn/ukIv0BqxtnjRgjuhJcGKO6jze1liPmZE/gm9YtnBtvQ20160921132139.jpg”,”createdtime”: “1474435299” } ]}}</p>
<h4 id="数据表"><a href="#数据表" class="headerlink" title="数据表"></a>数据表</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br></pre></td><td class="code"><pre><span class="line">CREATE TABLE `industry_category` (</span><br><span class="line">  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,</span><br><span class="line">  `category_id` char(8) NOT NULL,</span><br><span class="line">  `parent_id` char(8) NOT NULL,</span><br><span class="line">  `name` varchar(128) NOT NULL COMMENT &apos;行业名称&apos;,</span><br><span class="line">  PRIMARY KEY (`id`)</span><br><span class="line">) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT=&apos;国家统计局的两级行业分类标准&apos;</span><br><span class="line"></span><br><span class="line"># 保存从名片的json数据解析出来的数据 name * region</span><br><span class="line">CREATE TABLE `card_info_jsonver` (</span><br><span class="line">  `id` bigint(20) NOT NULL AUTO_INCREMENT,</span><br><span class="line">  `card_id` char(32) DEFAULT &apos;&apos; COMMENT &apos;名片id&apos;,</span><br><span class="line">  `user_id` char(40) DEFAULT &apos;&apos; COMMENT &apos;用户id&apos;,</span><br><span class="line">  `side` tinyint(4) DEFAULT &apos;0&apos; COMMENT &apos;名片的正反面，0：正面，1：反面&apos;,</span><br><span class="line">  `name` varchar(128) DEFAULT &apos;&apos; COMMENT &apos;名片上的名字&apos;,</span><br><span class="line">  `mobile` varchar(20) DEFAULT &apos;&apos; COMMENT &apos;手机号&apos;,</span><br><span class="line">  `provinceM` varchar(64) DEFAULT &apos;&apos; COMMENT &apos;手机号解出来的省份&apos;,</span><br><span class="line">  `provinceM_code` varchar(16) DEFAULT &apos;&apos; COMMENT &apos;省份编码&apos;,</span><br><span class="line">  `cityM` varchar(64) DEFAULT &apos;&apos; COMMENT &apos;城市&apos;,</span><br><span class="line">  `cityM_code` varchar(16) DEFAULT &apos;&apos; COMMENT &apos;城市编码&apos;,</span><br><span class="line">  `created_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT &apos;名片创建时间&apos;,</span><br><span class="line">  `updated_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT &apos;名片更新时间&apos;,</span><br><span class="line">  `handle_state` varchar(16) DEFAULT &apos;&apos; COMMENT &apos;处理状态&apos;,</span><br><span class="line">  PRIMARY KEY (`id`)</span><br><span class="line">) ENGINE=InnoDB AUTO_INCREMENT=42333 DEFAULT CHARSET=utf8 COMMENT=&apos;保存从名片的json数据解析出来的数据&apos;</span><br><span class="line"></span><br><span class="line"># 从名片json数据解析出来的公司信息 companyName * func</span><br><span class="line">CREATE TABLE `company_info_jsonVer` (</span><br><span class="line">  `id` bigint(20) NOT NULL AUTO_INCREMENT,</span><br><span class="line">  `card_id` char(32) DEFAULT NULL COMMENT &apos;名片id&apos;,</span><br><span class="line">  `user_id` char(40) DEFAULT NULL COMMENT &apos;用户id&apos;,</span><br><span class="line">  `companyName` varchar(128) DEFAULT NULL COMMENT &apos;公司名称&apos;,</span><br><span class="line">  `industry` varchar(128) DEFAULT NULL COMMENT &apos;二级行业&apos;,</span><br><span class="line">  `ind_code` char(8) DEFAULT NULL COMMENT &apos;二级行业编码&apos;,</span><br><span class="line">  `title` char(64) DEFAULT NULL COMMENT &apos;职位&apos;,</span><br><span class="line">  `func_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT &apos;职能名称&apos;,</span><br><span class="line">  `func_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT &apos;职能编号&apos;,</span><br><span class="line">  PRIMARY KEY (`id`)</span><br><span class="line">) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT=&apos;从名片json数据解析出来的公司信息&apos;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">消息类型</span><br><span class="line"> </span><br><span class="line">&#123;</span><br><span class="line">    &quot;messagetype&quot;: 230,</span><br><span class="line">    &quot;params&quot;: &#123;</span><br><span class="line">        &quot;data&quot;: [</span><br><span class="line">            &#123;</span><br><span class="line">                &quot;newsid&quot;: 资讯id,   </span><br><span class="line">                &quot;title&quot;: &quot;资讯标题&quot;,</span><br><span class="line">               &quot;url&quot;: &quot;资讯URL&quot;,</span><br><span class="line">                &quot;coverurl&quot;: &quot;封面URL&quot;,</span><br><span class="line">            &#125;,</span><br><span class="line">            ....</span><br><span class="line">        ]</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line">注：排序 按照data中数组的顺序</span><br></pre></td></tr></table></figure>
<hr>
<h3 id="用户推广"><a href="#用户推广" class="headerlink" title="用户推广"></a>用户推广</h3><p>基本流程与咨询推送相同</p>
<h4 id="仓库位置-1"><a href="#仓库位置-1" class="headerlink" title="仓库位置"></a>仓库位置</h4><p>git@192.168.30.251:message_handling.git</p>
<p>git@192.168.30.251:effective.git</p>
<p>userPromotion.py</p>
<h4 id="推广表"><a href="#推广表" class="headerlink" title="推广表"></a>推广表</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br></pre></td><td class="code"><pre><span class="line">CREATE TABLE `sys_user_promotion` (</span><br><span class="line">  `id` int(11) NOT NULL AUTO_INCREMENT,</span><br><span class="line">  `pro_id` char(32) NOT NULL COMMENT &apos;推广ID&apos;,</span><br><span class="line">  `type` tinyint(2) NOT NULL DEFAULT &apos;0&apos; COMMENT &apos;推送方式：1：内部 2：邮件 3：短信&apos;,</span><br><span class="line">  `isalluser` tinyint(2) NOT NULL DEFAULT &apos;1&apos; COMMENT &apos;1发送注册用户2发送全部用户&apos;,</span><br><span class="line">  `push_time` int(10) NOT NULL COMMENT &apos;设置的推送时间&apos;,</span><br><span class="line">  `region` varchar(2000) NOT NULL DEFAULT &apos;&apos; COMMENT &apos;地区（多个,号隔开）&apos;,</span><br><span class="line">  `industry` varchar(2000) NOT NULL DEFAULT &apos;&apos; COMMENT &apos;行业（多个,号隔开）&apos;,</span><br><span class="line">  `func` varchar(2000) NOT NULL DEFAULT &apos;&apos; COMMENT &apos;职能（多个,号隔开）&apos;,</span><br><span class="line">  `title` varchar(50) CHARACTER SET utf8mb4 DEFAULT &apos;&apos; COMMENT &apos;标题&apos;,</span><br><span class="line">  `content` text NOT NULL COMMENT &apos;推送的内容&apos;,</span><br><span class="line">  `created_time` int(10) NOT NULL COMMENT &apos;添加时间&apos;,</span><br><span class="line">  `admin_id` char(40) NOT NULL DEFAULT &apos;&apos; COMMENT &apos;设置人&apos;,</span><br><span class="line">  `status` tinyint(2) NOT NULL DEFAULT &apos;1&apos; COMMENT &apos;状态 1：未发 2：已发&apos;,</span><br><span class="line">  `isntice` tinyint(2) DEFAULT &apos;0&apos; COMMENT &apos;是否通知&apos;,</span><br><span class="line">  `url` varchar(256) NOT NULL COMMENT &apos;url地址&apos;,</span><br><span class="line">  `json_data` text NOT NULL COMMENT &apos;推送json格式&apos;,</span><br><span class="line">  PRIMARY KEY (`id`)</span><br><span class="line">) ENGINE=InnoDB AUTO_INCREMENT=58 DEFAULT CHARSET=utf8 COMMENT=&apos;运营后台-用户推广表&apos;</span><br><span class="line"></span><br><span class="line">-- 存储type为2，3的用户推广</span><br><span class="line">CREATE TABLE `message_promotion` (</span><br><span class="line">  `id` bigint(20) NOT NULL AUTO_INCREMENT,</span><br><span class="line">  `type` tinyint(4) NOT NULL DEFAULT &apos;0&apos; COMMENT &apos;类型：1-内部，2-邮件，3-短信&apos;,</span><br><span class="line">  `mobile` varchar(18) DEFAULT &apos;&apos; COMMENT &apos;手机号&apos;,</span><br><span class="line">  `email` varchar(256) DEFAULT &apos;&apos; COMMENT &apos;邮箱&apos;,</span><br><span class="line">  `title` varchar(100) NOT NULL DEFAULT &apos;&apos; COMMENT &apos;标题&apos;,</span><br><span class="line">  `content` text NOT NULL COMMENT &apos;消息内容&apos;,</span><br><span class="line">  `created_time` int(11) DEFAULT NULL COMMENT &apos;创建时间&apos;,</span><br><span class="line">  `modified_time` int(11) DEFAULT NULL COMMENT &apos;修改时间&apos;,</span><br><span class="line">  `status` tinyint(4) NOT NULL DEFAULT &apos;0&apos; COMMENT &apos;状态：0-未发送，1-已发送，2-发送失败&apos;,</span><br><span class="line">  PRIMARY KEY (`id`)</span><br><span class="line">) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COMMENT=&apos;推广消息表&apos;</span><br><span class="line"> </span><br><span class="line">推广消息类型</span><br><span class="line"> </span><br><span class="line">&#123;</span><br><span class="line">  &quot;messagetype&quot;:231,</span><br><span class="line">  &quot;params&quot;:&#123;</span><br><span class="line">     &quot;id&quot;:&quot;文章id&quot;，</span><br><span class="line">      &quot;title&quot;: &quot;资讯标题&quot;,</span><br><span class="line">      &quot;content&quot;:&quot;内容&quot;，</span><br><span class="line">      &quot;createdtime&quot;: &quot;1345764830&quot;</span><br><span class="line">   &#125;</span><br><span class="line">&#125;</span><br><span class="line">&#123;</span><br><span class="line">  &quot;messagetype&quot;: 231,</span><br><span class="line">  &quot;params&quot;: &#123;</span><br><span class="line">    &quot;content&quot;: &quot;hello world！&lt;br/&gt;&quot;,</span><br><span class="line">    &quot;createdtime&quot;: 1483620281,</span><br><span class="line">    &quot;id&quot;: &quot;zlJjJD6gDvjCdoMcibqCWOGrMo7vbB0b&quot;,</span><br><span class="line">    &quot;image&quot;: &quot;&quot;,</span><br><span class="line">    &quot;title&quot;: &quot;推送测试&quot;,</span><br><span class="line">    &quot;type&quot;: &quot;user&quot;,</span><br><span class="line">    &quot;url&quot;: &quot;h5/News/secretary?type=promotion&amp;id=zlJjJD6gDvjCdoMcibqCWOGrMo7vbB0b&quot;</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<hr>
<h3 id="活动管理"><a href="#活动管理" class="headerlink" title="活动管理"></a>活动管理</h3><h4 id="背景说明"><a href="#背景说明" class="headerlink" title="背景说明"></a>背景说明</h4><p>系统中，内容管理-推送、运营管理-新增推广、运营管理-新增活动页面中，地区、行业、职能选择时，弹窗样式与“内容管理-推送”样式相同，具体请参见原型</p>
<p>进行推送时，匹配规则如下：<br>a)  行业：第一次使用APP时所选行业+当前默认身份的并集。采用1级行业-2级行业模式划分<br>b)  地区：第一次使用APP时所选手机号+当前默认身份的并集。采用1级地区-2级地区模式划分<br>c)  职能：当前默认身份。采用1级行业-职能（只有1级）模式划分</p>
<p>当前默认身份cardid需要通过表 account_basic_detail 的 card_id 字段得到</p>
<h4 id="业务流程"><a href="#业务流程" class="headerlink" title="业务流程"></a>业务流程</h4><h4 id="仓库位置-2"><a href="#仓库位置-2" class="headerlink" title="仓库位置"></a>仓库位置</h4><p>git@192.168.30.251:message_handling.git</p>
<p>OperationActivity</p>
<h4 id="活动表结构"><a href="#活动表结构" class="headerlink" title="活动表结构"></a>活动表结构</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br></pre></td><td class="code"><pre><span class="line">CREATE TABLE `operation_activity` (</span><br><span class="line">  `id` int(11) NOT NULL AUTO_INCREMENT,</span><br><span class="line">  `activity_id` char(32) CHARACTER SET utf8 NOT NULL COMMENT &apos;活动id&apos;,</span><br><span class="line">  `type` tinyint(4) NOT NULL DEFAULT &apos;1&apos; COMMENT &apos;类型 1:活动 2:资讯&apos;,</span><br><span class="line">  `isnotify` tinyint(4) NOT NULL DEFAULT &apos;1&apos; COMMENT &apos;1:不通知 2:通知&apos;,</span><br><span class="line">  `push_state` tinyint(4) NOT NULL DEFAULT &apos;1&apos; COMMENT &apos;isnotify为2时有效，1:未推送，2:已推送&apos;,</span><br><span class="line">  `region` varchar(256) CHARACTER SET utf8 NOT NULL COMMENT &apos;地区（多个,号隔开）&apos;,</span><br><span class="line">  `industry` varchar(256) CHARACTER SET utf8 NOT NULL COMMENT &apos;行业（多个,号隔开）&apos;,</span><br><span class="line">  `func` varchar(256) CHARACTER SET utf8 NOT NULL COMMENT &apos;职能（多个,号隔开）&apos;,</span><br><span class="line">  `show_id` varchar(400) CHARACTER SET utf8 DEFAULT NULL COMMENT &apos;资讯shwo_id（多个,号隔开）type为2时有效&apos;,</span><br><span class="line">  `image` varchar(256) CHARACTER SET utf8 DEFAULT NULL COMMENT &apos;标题图片&apos;,</span><br><span class="line">  `title` varchar(100) CHARACTER SET utf8 DEFAULT NULL COMMENT &apos;活动标题 type为1时使用&apos;,</span><br><span class="line">  `content` text CHARACTER SET utf8 COMMENT &apos;活动标题 type为1时使用&apos;,</span><br><span class="line">  `onlinetime` int(11) NOT NULL DEFAULT &apos;0&apos; COMMENT &apos;上线时间&apos;,</span><br><span class="line">  `offlinetime` int(11) NOT NULL DEFAULT &apos;0&apos; COMMENT &apos;下线时间&apos;,</span><br><span class="line">  `user_id` char(40) CHARACTER SET utf8 NOT NULL COMMENT &apos;发布人用户id&apos;,</span><br><span class="line">  `created_time` int(11) NOT NULL DEFAULT &apos;0&apos; COMMENT &apos;创建时间&apos;,</span><br><span class="line">  `modify_time` int(11) NOT NULL DEFAULT &apos;0&apos; COMMENT &apos;修改时间&apos;,</span><br><span class="line">  `state` tinyint(4) NOT NULL DEFAULT &apos;1&apos; COMMENT &apos;状态 1:未发布 2:已发布 3:已下线 4:已删除&apos;,</span><br><span class="line">  `click_count` int(11) NOT NULL DEFAULT &apos;0&apos; COMMENT &apos;点击量&apos;,</span><br><span class="line">  `share_count` int(11) NOT NULL DEFAULT &apos;0&apos; COMMENT &apos;分享量&apos;,</span><br><span class="line">  `share_user_count` int(11) NOT NULL DEFAULT &apos;0&apos; COMMENT &apos;分享用户量&apos;,</span><br><span class="line">  `push_count` int(11) NOT NULL DEFAULT &apos;0&apos; COMMENT &apos;推送用户量&apos;,</span><br><span class="line">  `url` varchar(256) NOT NULL COMMENT &apos;URL地址&apos;,</span><br><span class="line">  `json_data` text NOT NULL,</span><br><span class="line">  PRIMARY KEY (`id`),</span><br><span class="line">  UNIQUE KEY `activity_id` (`activity_id`)</span><br><span class="line">) ENGINE=InnoDB AUTO_INCREMENT=94 DEFAULT CHARSET=utf8mb4 COMMENT=&apos;运营活动表&apos;</span><br><span class="line"></span><br><span class="line">推送类型</span><br><span class="line">&#123;</span><br><span class="line">  &quot;messagetype&quot;:231,</span><br><span class="line">  &quot;params&quot;:&#123;</span><br><span class="line">      &quot;id&quot;:&quot;文章id&quot;，</span><br><span class="line">      &quot;title&quot;: &quot;标题&quot;,</span><br><span class="line">      &quot;content&quot;:&quot;内容&quot;，</span><br><span class="line">      &quot;createdtime&quot;: &quot;1345764830&quot;,</span><br><span class="line">      &quot;image&quot;:&quot;图片URL&quot;，</span><br><span class="line">      &quot;type&quot;:&quot;活动（activity）或者用户推广（user）&quot;</span><br><span class="line">   &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<hr>
<h3 id="带推送消息查询语句"><a href="#带推送消息查询语句" class="headerlink" title="带推送消息查询语句"></a>带推送消息查询语句</h3><h4 id="资讯推送-1"><a href="#资讯推送-1" class="headerlink" title="资讯推送"></a>资讯推送</h4><p>select id,FROM_UNIXTIME(push_time) as push_time,status,region,industry,func,admin_id,content from oradt_cloud_test2.sns_qa_push_setting<br>where <code>status</code> &lt;&gt; 2 and industry != ‘’ and func != ‘’ and region != ‘’<br>and ROUND((UNIX_TIMESTAMP(SYSDATE()) - push_time)/60) &gt;= -2;</p>
<h4 id="用户推广-1"><a href="#用户推广-1" class="headerlink" title="用户推广"></a>用户推广</h4><p>select id,FROM_UNIXTIME(push_time) as push_time,status,region,industry,func,admin_id,title,json_data from oradt_cloud_test2.sys_user_promotion<br>where <code>status</code> &lt;&gt; 2 and industry != ‘’ and func != ‘’ and region != ‘’<br>and ROUND((UNIX_TIMESTAMP(SYSDATE()) - push_time)/60) &gt;= -2;</p>
<h4 id="活动推广"><a href="#活动推广" class="headerlink" title="活动推广"></a>活动推广</h4><p>select id,push_state, region, industry, func, title, json_data, user_id from oradt_cloud_test2.operation_activity<br>where push_state &lt;&gt; 2 and industry != ‘’ and func != ‘’ and region != ‘’ and ROUND((UNIX_TIMESTAMP(SYSDATE()) - push_time)/60) &gt;= -2;</p>
<hr>
<h3 id="部署情况"><a href="#部署情况" class="headerlink" title="部署情况"></a>部署情况</h3><h4 id="125仿真环境"><a href="#125仿真环境" class="headerlink" title="125仿真环境"></a>125仿真环境</h4><p>部署在IDC 云主机 /home/xieqj/python2.7_scenario/fangzhen</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">0 */1 * * * python2.7 /home/xieqj/python2.7_scenario/fangzhen/CardDeduplication/CardDeduplication3366.py</span><br></pre></td></tr></table></figure>
<p>名片去重 60分钟运行一次<br>名片异常 5分钟运行一次<br>人脉更新 60分钟运行一次<br>消息推送 main.py 60分钟一次</p>
<p>python2.7 运行的是125 3366端口<br>python2.7 message_handling/main.py (消息推送)<br>python2.7 CardDeduplication/CardDeduplication.py<br>python2.7 CardExceptionHandling/CardException.py<br>python2.7 cardUpdateNotification/CardUpdateNote.py</p>
<p>python 运行的是3388端口<br>python CardDeduplication.py<br>python CardException.py</p>
<h4 id="AWS"><a href="#AWS" class="headerlink" title="AWS"></a>AWS</h4><p>部署在ec2 54.223.28.119<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">0 0 */1 * * python2.7 /home/ec2-user/namecard/CardDeduplication/CardDeduplication_aws.py</span><br></pre></td></tr></table></figure></p>
<p>名片异常 每5分钟运行一次<br>名片去重 每24小时运行一次<br>用户推广 每1分钟运行一次<br>消息推送 每1分钟运行一次</p>

      
    </div>
    
    
    

    
      <div>
        <div id="wechat_subscriber" style="display: block; padding: 10px 0; margin: 20px auto; width: 100%; text-align: center">
    <img id="wechat_subscriber_qcode" src="/uploads/wechat-qcode.jpg" alt="Frone Xie wechat" style="width: 200px; max-width: 100%;"/>
    <div>欢迎关注我的微信公众号！</div>
</div>

      </div>
    

    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/msyql/" rel="tag"># msyql</a>
          
            <a href="/tags/message-queue/" rel="tag"># message queue</a>
          
        </div>
      

      
      
        <div class="post-widgets">
        

        

        
          
          <div id="needsharebutton-postbottom">
            <span class="btn">
              <i class="fa fa-share-alt" aria-hidden="true"></i>
            </span>
          </div>
        
        </div>
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2017/02/10/Hdfs1/" rel="next" title="Hdfs的block块">
                <i class="fa fa-chevron-left"></i> Hdfs的block块
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2017/02/15/monthlyReport/" rel="prev" title="月报各统计指标计算方法">
                月报各统计指标计算方法 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <p class="site-author-name" itemprop="name">Frone Xie</p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/">
              
                  <span class="site-state-item-count">29</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/categories/index.html">
                  <span class="site-state-item-count">10</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/tags/index.html">
                  <span class="site-state-item-count">45</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          

          
            <div class="links-of-author motion-element">
                
                  <span class="links-of-author-item">
                    <a href="https://github.com/frone" target="_blank" title="GitHub">
                      
                        <i class="fa fa-fw fa-github"></i>GitHub</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="https://blog.csdn.net/frone" target="_blank" title="CSDN">
                      
                        <i class="fa fa-fw fa-CSDN"></i>CSDN</a>
                  </span>
                
            </div>
          

          
          

          
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-3"><a class="nav-link" href="#整体启动"><span class="nav-number">1.</span> <span class="nav-text">整体启动</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#相关配置"><span class="nav-number">1.1.</span> <span class="nav-text">相关配置</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#资讯推送"><span class="nav-number">2.</span> <span class="nav-text">资讯推送</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#仓库位置"><span class="nav-number">2.1.</span> <span class="nav-text">仓库位置</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#数据表"><span class="nav-number">2.2.</span> <span class="nav-text">数据表</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#用户推广"><span class="nav-number">3.</span> <span class="nav-text">用户推广</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#仓库位置-1"><span class="nav-number">3.1.</span> <span class="nav-text">仓库位置</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#推广表"><span class="nav-number">3.2.</span> <span class="nav-text">推广表</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#活动管理"><span class="nav-number">4.</span> <span class="nav-text">活动管理</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#背景说明"><span class="nav-number">4.1.</span> <span class="nav-text">背景说明</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#业务流程"><span class="nav-number">4.2.</span> <span class="nav-text">业务流程</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#仓库位置-2"><span class="nav-number">4.3.</span> <span class="nav-text">仓库位置</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#活动表结构"><span class="nav-number">4.4.</span> <span class="nav-text">活动表结构</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#带推送消息查询语句"><span class="nav-number">5.</span> <span class="nav-text">带推送消息查询语句</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#资讯推送-1"><span class="nav-number">5.1.</span> <span class="nav-text">资讯推送</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#用户推广-1"><span class="nav-number">5.2.</span> <span class="nav-text">用户推广</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#活动推广"><span class="nav-number">5.3.</span> <span class="nav-text">活动推广</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#部署情况"><span class="nav-number">6.</span> <span class="nav-text">部署情况</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#125仿真环境"><span class="nav-number">6.1.</span> <span class="nav-text">125仿真环境</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#AWS"><span class="nav-number">6.2.</span> <span class="nav-text">AWS</span></a></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2019</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Frone Xie</span>

  
</div>


  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Pisces</a> v5.1.4</div>




        
<div class="busuanzi-count">
  <script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>

  
    <span class="site-uv">
      <i class="fa fa-user">本站访客数</i>
      <span class="busuanzi-value" id="busuanzi_value_site_uv"></span>
      人数
    </span>
  

  
    <span class="site-pv">
      <i class="fa fa-eye">本站总访问量</i>
      <span class="busuanzi-value" id="busuanzi_value_site_pv"></span>
      次
    </span>
  
</div>





  <script type="text/javascript">
    (function() {
      var hm = document.createElement("script");
      hm.src = "//tajs.qq.com/stats?sId=65946112";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>




        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    
      <div id="needsharebutton-float">
        <span class="btn">
          <i class="fa fa-share-alt" aria-hidden="true"></i>
        </span>
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.4"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  





  

  
  <script src="https://cdn1.lncld.net/static/js/av-core-mini-0.6.4.js"></script>
  <script>AV.initialize("ohqkXUU5txOlX3MjJPCrw7jG-gzGzoHsz", "bPQhLzRSEsTqdIKAGRcHLhyN");</script>
  <script>
    function showTime(Counter) {
      var query = new AV.Query(Counter);
      var entries = [];
      var $visitors = $(".leancloud_visitors");

      $visitors.each(function () {
        entries.push( $(this).attr("id").trim() );
      });

      query.containedIn('url', entries);
      query.find()
        .done(function (results) {
          var COUNT_CONTAINER_REF = '.leancloud-visitors-count';

          if (results.length === 0) {
            $visitors.find(COUNT_CONTAINER_REF).text(0);
            return;
          }

          for (var i = 0; i < results.length; i++) {
            var item = results[i];
            var url = item.get('url');
            var time = item.get('time');
            var element = document.getElementById(url);

            $(element).find(COUNT_CONTAINER_REF).text(time);
          }
          for(var i = 0; i < entries.length; i++) {
            var url = entries[i];
            var element = document.getElementById(url);
            var countSpan = $(element).find(COUNT_CONTAINER_REF);
            if( countSpan.text() == '') {
              countSpan.text(0);
            }
          }
        })
        .fail(function (object, error) {
          console.log("Error: " + error.code + " " + error.message);
        });
    }

    function addCount(Counter) {
      var $visitors = $(".leancloud_visitors");
      var url = $visitors.attr('id').trim();
      var title = $visitors.attr('data-flag-title').trim();
      var query = new AV.Query(Counter);

      query.equalTo("url", url);
      query.find({
        success: function(results) {
          if (results.length > 0) {
            var counter = results[0];
            counter.fetchWhenSave(true);
            counter.increment("time");
            counter.save(null, {
              success: function(counter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(counter.get('time'));
              },
              error: function(counter, error) {
                console.log('Failed to save Visitor num, with error message: ' + error.message);
              }
            });
          } else {
            var newcounter = new Counter();
            /* Set ACL */
            var acl = new AV.ACL();
            acl.setPublicReadAccess(true);
            acl.setPublicWriteAccess(true);
            newcounter.setACL(acl);
            /* End Set ACL */
            newcounter.set("title", title);
            newcounter.set("url", url);
            newcounter.set("time", 1);
            newcounter.save(null, {
              success: function(newcounter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(newcounter.get('time'));
              },
              error: function(newcounter, error) {
                console.log('Failed to create');
              }
            });
          }
        },
        error: function(error) {
          console.log('Error:' + error.code + " " + error.message);
        }
      });
    }

    $(function() {
      var Counter = AV.Object.extend("Counter");
      if ($('.leancloud_visitors').length == 1) {
        addCount(Counter);
      } else if ($('.post-title-link').length > 1) {
        showTime(Counter);
      }
    });
  </script>



  

  

  
  
  
  <link rel="stylesheet" href="/lib/needsharebutton/needsharebutton.css">

  
  
  <script src="/lib/needsharebutton/needsharebutton.js"></script>

  <script>
    
      pbOptions = {};
      
          pbOptions.iconStyle = "box";
      
          pbOptions.boxForm = "horizontal";
      
          pbOptions.position = "bottomCenter";
      
          pbOptions.networks = "Weibo,Wechat,Douban,QQZone,Twitter,Facebook";
      
      new needShareButton('#needsharebutton-postbottom', pbOptions);
    
    
      flOptions = {};
      
          flOptions.iconStyle = "box";
      
          flOptions.boxForm = "horizontal";
      
          flOptions.position = "middleRight";
      
          flOptions.networks = "Weibo,Wechat,Douban,QQZone,Twitter,Facebook";
      
      new needShareButton('#needsharebutton-float', flOptions);
    
  </script>

  

  
  
    <script type="text/x-mathjax-config">
      MathJax.Hub.Config({
        tex2jax: {
          inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
          processEscapes: true,
          skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
        }
      });
    </script>

    <script type="text/x-mathjax-config">
      MathJax.Hub.Queue(function() {
        var all = MathJax.Hub.getAllJax(), i;
        for (i=0; i < all.length; i += 1) {
          all[i].SourceElement().parentNode.className += ' has-jax';
        }
      });
    </script>
    <script type="text/javascript" src="//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
  


  

  

  <script type="text/javascript" src="/js/src/love.js"></script><!-- hexo-inject:begin --><!-- hexo-inject:end -->
</body>
</html>
